package com.wesley.spbtprovider.service;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import com.wesley.spbtprovider.dao.Admin2Dao;
import com.wesley.spbtprovider.dao.Admin3Dao;
import com.wesley.spbtprovider.entity.Admin;


@Service
public class AdminService {
	
	@Autowired
	private Admin3Dao adminDao;
	
	@Autowired
	private Admin2Dao admin2Dao;
	
	
	public Admin findOne(Integer id) {
		return adminDao.findOne(id);
	}
	
	@Transactional
	public Admin save(Admin entity) {
		return adminDao.save(entity);
	}
	
	
	@Transactional
	public void delete(Integer id) {
		adminDao.delete(id);
	}
	
	
	public Admin getByName(String name) {
		return admin2Dao.getByName(name);
	}
	
	public Admin getByIdAndName(Integer id,String name){
		return admin2Dao.getByIdAndName(id,name);
	}
	
	
	public Page<Admin> getByPage(Integer page) {
		PageRequest pageRequest = new PageRequest(page, 5);
		Page<Admin> pageInfo = adminDao.findAll(pageRequest);
		return pageInfo;
	}
	
}
